package main

import (
	"log"
	"time"

	"github.com/gin-gonic/gin"
)

// 同步
func Sync(c *gin.Context) {
	time.Sleep(5 * time.Second)
	log.Println("Sync " + c.Request.URL.Path)
}

// 异步
func Async(c *gin.Context) {
	cCp := c.Copy()
	go func() {
		time.Sleep(5 * time.Second)
		log.Println("Async " + cCp.Request.URL.Path)
	}()
}

func main() {
	r := gin.Default()

	r.GET("/long_sync", Sync)
	r.GET("/long_async", Async)

	r.Run()

}
